﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using System.Data;
using System.Data.SqlClient;
using Dapper;

namespace DapperTest1
{
    class Program
    {



        static void Main(string[] args)
        {
            SqlConnection connection = new SqlConnection("server=192.168.1.9\\JXDATABASE;database=jx_tongda;uid=sa;pwd=123;Max pool size=500");
            connection.Open();
            int i = 0;
            var x = connection.Query("select id,mc,sfzh,dizhi,k1ksrq from rq_jbxxb where km1_hg='1'");
            foreach (var item in x)
            {
                i++;
                Console.WriteLine("name: " + item.mc + " 身份证号: " + item.sfzh + " 科一考试日期: " + item.k1ksrq);
            }

            var xx = connection.Query<User>("select id,mc,sfzh,dizhi,k1ksrq from rq_jbxxb where km1_hg='1'");
            foreach (var item in xx)
            {
                i++;
                Console.WriteLine("name: " + item.Mc + " 身份证号: " + item.Sfzh + " 科一考试日期: " + item.K1ksrq);
            }

            var xxs = connection.Query<User>("select id,mc,sfzh,dizhi,k1ksrq from rq_jbxxb where km1_hg=@kshg", new { kshg = '1' });
            foreach (var item in xxs)
            {
                i++;
                Console.WriteLine("name: " + item.Mc + " 身份证号: " + item.Sfzh + " 科一考试日期: " + item.K1ksrq);
            }
            var xxsa = connection.Query<User>("select id,mc,sfzh,dizhi,k1ksrq from rq_jbxxb where km1_hg=@kshg", new { kshg = '1' }).Where(m => m.Mc.Contains("普通"));
            foreach (var item in xxsa)
            {
                i++;
                Console.WriteLine("name: " + item.Mc + " 身份证号: " + item.Sfzh + " 科一考试日期: " + item.K1ksrq);
            }

            Console.WriteLine("数量： " + i);
            connection.Close();
            Console.ReadKey();
        }
    }

    class User
    {
        public int Id { get; set; }
        public string Mc { get; set; }
        public string  Sfzh { get; set; }
        public string Dizhi { get; set; }
        public DateTime K1ksrq { get; set; }
    }
}
